// mock/user.ts
import mockJS from 'mockjs'

function randomName() {
  const isChinese = Math.random() > 0.5
  return isChinese ? '@cname' : '@first @last'
}

const userList = mockJS.mock({
  'data|20': [
    {
      name: () => randomName(),
      nickname: () => randomName(),
      'id|+1': 1,
      avatar: mockJS.Random.image('100x100', '#16d46b', '#fff', 'png', 'Hello'),
      time: '@time',
      date: '@date'
    }
  ]
})

module.exports = [
  {
    method: 'post',
    url: '/api/user/getUserList',
    response: ({ body }) => {
      return {
        code: 200,
        msg: 'success',
        ...userList
      }
    }
  }
]
